{smcl}
{txt}{sf}{ul off}{.-}
      name:  {res}<unnamed>
       {txt}log:  {res}E:\Github\Bolivia\00_replication_files\log-files/3_Table_1.smcl
  {txt}log type:  {res}smcl
 {txt}opened on:  {res}25 Jan 2022, 22:40:00
{txt}
{com}. 
. timer on 2
{txt}
{com}. 
. * Loading rdrobust_export, which is a program written by us to export results
. * from rdrobust
. cap program drop rdrobust_export
{txt}
{com}. include "codes/auxiliary_programs/rdrobust_export.ado"
{txt}
{com}. capture program drop rdrobust_export
{txt}
{com}. program define rdrobust_export, eclass
{txt}  1{com}. 
.         syntax anything [if] [in] [, fuzzy(string) h(string) kernel(string) file(string) ///
>                 apprep(string) vce(string) c(string) covs(string) p(string) colstring(string) bwselect(string) ///
>                 reguterm(string)]
{txt}  2{com}. 
.         preserve
{txt}  3{com}.                 tokenize "`anything'"
{txt}  4{com}.                 local dep `1'
{txt}  5{com}.                 local indep `2'
{txt}  6{com}. 
.                 *Global that will extract results from rdrobust
.                 global results "N_h_l N_h_r h_l h_r tau_cl tau_bc se_tau_cl se_tau_rb"
{txt}  7{com}. 
.                 *-----------------------*
.                 * Producing the Results *
.                 *-----------------------*
.                 * Type of kernel
.                 if "`kernel'"=="" {c -(}
{txt}  8{com}.                         local ker=""
{txt}  9{com}.                 {c )-}
{txt} 10{com}.                 else if "`kernel'"!="" {c -(}
{txt} 11{com}.                         local ker="kernel(`kernel')"
{txt} 12{com}.                 {c )-}
{txt} 13{com}. 
.                 * h bandwidth
.                 if "`h'"=="" {c -(}
{txt} 14{com}.                         local h_band=""
{txt} 15{com}.                 {c )-}
{txt} 16{com}.                 else if "`h'"!="" {c -(}
{txt} 17{com}.                         local h_band="h(`h' `h')"
{txt} 18{com}.                 {c )-}
{txt} 19{com}. 
.                 * Type of VCE
.                 if "`vce'"=="" {c -(}
{txt} 20{com}.                         local vce_type=""
{txt} 21{com}.                 {c )-}
{txt} 22{com}.                 else if "`vce'"!="" {c -(}
{txt} 23{com}.                         local vce_type="vce(`vce')"
{txt} 24{com}.                 {c )-}
{txt} 25{com}. 
.                 * c cutoff
.                 if "`c'"=="" {c -(}
{txt} 26{com}.                         local cutoff=""
{txt} 27{com}.                 {c )-}
{txt} 28{com}.                 else if "`c'"!="" {c -(}
{txt} 29{com}.                         local cutoff="c(`c')"
{txt} 30{com}.                 {c )-}
{txt} 31{com}. 
.                 * Covariates
.                 if "`covs'"=="" {c -(}
{txt} 32{com}.                         local covariates=""
{txt} 33{com}.                 {c )-}
{txt} 34{com}.                 else if "`covs'"!="" {c -(}
{txt} 35{com}.                         local covariates="covs(`covs')"
{txt} 36{com}.                 {c )-}
{txt} 37{com}. 
.                 * Polynomial order
.                 if "`p'"=="" {c -(}
{txt} 38{com}.                         local poly=""
{txt} 39{com}.                 {c )-}
{txt} 40{com}.                 else if "`p'"!="" {c -(}
{txt} 41{com}.                         local poly="p(`p')"
{txt} 42{com}.                 {c )-}
{txt} 43{com}. 
.                 * Fuzzy
.                 if "`fuzzy'"=="" {c -(}
{txt} 44{com}.                         local fuz=""
{txt} 45{com}.                 {c )-}
{txt} 46{com}.                 else if "`fuzzy'"!="" {c -(}
{txt} 47{com}.                         local fuz="fuzzy(`fuzzy')"
{txt} 48{com}.                 {c )-}
{txt} 49{com}. 
.                 * Bwselect
.                 if "`bwselect'"=="" {c -(}
{txt} 50{com}.                         local bw=""
{txt} 51{com}.                 {c )-}
{txt} 52{com}.                 else if "`bwselect'"!="" {c -(}
{txt} 53{com}.                         local bw="bwselect(`bwselect')"
{txt} 54{com}.                 {c )-}
{txt} 55{com}. 
.                 * Regularization term
.                 if "`reguterm'"=="" {c -(}
{txt} 56{com}.                         local rt=""
{txt} 57{com}.                 {c )-}
{txt} 58{com}.                 else if "`reguterm'"!="" {c -(}
{txt} 59{com}.                         local rt="scaleregul(0)"
{txt} 60{com}.                 {c )-}
{txt} 61{com}. 
.                 *Estimating
.                 rdrobust `dep' `indep' `if', ///
>                         all `fuz' `ker' `h_band' `vce_type' `cutoff' `covariates' `poly' `bw' `rt'
{txt} 62{com}. 
.                 *Extracting results
.                 foreach x of global results {c -(}
{txt} 63{com}.                         local `x'_res=e(`x')
{txt} 64{com}.                 {c )-}
{txt} 65{com}. 
.                 *-------------------------*
.                 * Constructing the Tables *
.                 *-------------------------*
.                 clear
{txt} 66{com}.                 set obs 1
{txt} 67{com}. 
.                 * Filling the table
.                 foreach b in estim band_l band_r conv_pv conv_ci_low conv_ci_high rob_pv rob_ci_low rob_ci_high obs_l obs_r obs {c -(}
{txt} 68{com}.                         gen `b'=.
{txt} 69{com}.                 {c )-}
{txt} 70{com}. 
.                 replace estim=`tau_cl_res'
{txt} 71{com}. 
.                 replace band_l=`h_l_res'
{txt} 72{com}.                 replace band_r=`h_r_res'
{txt} 73{com}. 
.                 replace conv_pv=2*normal(-abs(`tau_cl_res'/`se_tau_cl_res'))
{txt} 74{com}.                 replace conv_ci_low=`tau_cl_res'-invnormal(0.975)*`se_tau_cl_res'
{txt} 75{com}.                 replace conv_ci_high=`tau_cl_res'+invnormal(0.975)*`se_tau_cl_res'
{txt} 76{com}. 
.                 replace rob_pv=2*normal(-abs(`tau_bc_res'/`se_tau_rb_res'))
{txt} 77{com}.                 replace rob_ci_low=`tau_bc_res'-invnormal(0.975)*`se_tau_rb_res'
{txt} 78{com}.                 replace rob_ci_high=`tau_bc_res'+invnormal(0.975)*`se_tau_rb_res'
{txt} 79{com}. 
.                 replace obs_l=`N_h_l_res'
{txt} 80{com}.                 replace obs_r=`N_h_r_res'
{txt} 81{com}.                 replace obs=`N_h_l_res'+`N_h_r_res'
{txt} 82{com}. 
.                 if "`colstring'"!="" {c -(}
{txt} 83{com}.                         gen colstring="`colstring'"
{txt} 84{com}.                 {c )-}
{txt} 85{com}. 
.                 save "tempfile.dta", replace
{txt} 86{com}.                 
.                 *--------------------------------*
.                 * Appending or replacing to save *
.                 *--------------------------------*
.                 if "`apprep'"=="replace" {c -(}
{txt} 87{com}.                         erase "tempfile.dta"
{txt} 88{com}.                 {c )-}
{txt} 89{com}.                 else if "`apprep'"=="append" {c -(}
{txt} 90{com}.                         use "`file'.dta", clear
{txt} 91{com}. 
.                         append using "tempfile.dta"
{txt} 92{com}.                         erase "tempfile.dta"
{txt} 93{com}.                 {c )-}
{txt} 94{com}. 
.                 save "`file'.dta", replace
{txt} 95{com}.         restore
{txt} 96{com}. end
{txt}
{com}. {txt}
{com}. 
. * Loading myround, which is a program written by us to round numbers
. cap program drop myround
{txt}
{com}. include "codes/auxiliary_programs/myround.ado"
{txt}
{com}. capture program drop myround
{txt}
{com}. program define myround, eclass
{txt}  1{com}.         syntax varlist (min=1 max=1 numeric), decimals(numlist min=1 max=1)
{txt}  2{com}.         
.         tokenize `varlist'
{txt}  3{com}.         local var "`1'"
{txt}  4{com}.         
.         tostring `var', gen(temp_str) force
{txt}  5{com}. 
.         replace temp_str="0.00000" if strpos(temp_str,"e-")>0 & substr(temp_str,1,1)!="-"
{txt}  6{com}.         replace temp_str="-0.00000" if strpos(temp_str,"e-")>0 & substr(temp_str,1,1)=="-"
{txt}  7{com}.         
.         split temp_str, p(".")
{txt}  8{com}.         local nv=r(nvars)
{txt}  9{com}.         if `nv'>1 {c -(}
{txt} 10{com}.                 replace temp_str1="0" if temp_str1==""
{txt} 11{com}.                 replace temp_str1="-0" if temp_str1=="-"
{txt} 12{com}.                 
.                 local flag=0
{txt} 13{com}.                 while `flag'==0 {c -(}
{txt} 14{com}.                         cap drop length2
{txt} 15{com}.                         gen length2=length(temp_str2)
{txt} 16{com}.                         replace temp_str2=temp_str2+"0" if length2<`decimals'+1
{txt} 17{com}.                         
.                         drop length2
{txt} 18{com}.                         gen length2=length(temp_str2)
{txt} 19{com}.                         quietly sum length2
{txt} 20{com}.                         local min=r(min)-1
{txt} 21{com}.                         if `min'>=`decimals' {c -(}
{txt} 22{com}.                                 local flag=1
{txt} 23{com}.                         {c )-}
{txt} 24{com}.                 {c )-}
{txt} 25{com}.                 cap drop length2
{txt} 26{com}.                 
.                 gen var_first_tpositions=substr(temp_str2,1,`decimals')
{txt} 27{com}.                 local t=`decimals'+1
{txt} 28{com}.                 gen var_tthpos=substr(temp_str2,`t',1)
{txt} 29{com}.                 destring var_first_tpositions var_tthpos, force replace
{txt} 30{com}.                 replace var_first_tpositions=var_first_tpositions+1 if var_tthpos>=5
{txt} 31{com}.                 replace var_first_tpositions=var_first_tpositions+0 if var_tthpos<5
{txt} 32{com}.                 
.                 tostring var_first_tpositions, force replace
{txt} 33{com}.                 local flag=0
{txt} 34{com}.                 while `flag'==0 {c -(}
{txt} 35{com}.                         cap drop length1
{txt} 36{com}.                         gen length1=length(var_first_tpositions)
{txt} 37{com}.                         replace var_first_tpositions="0"+var_first_tpositions if length1<`decimals'
{txt} 38{com}.                         
.                         cap drop length1
{txt} 39{com}.                         gen length1=length(var_first_tpositions)
{txt} 40{com}.                         quietly sum length1
{txt} 41{com}.                         local min=r(min)
{txt} 42{com}.                         if `min'>=`decimals' {c -(}
{txt} 43{com}.                                 local flag=1
{txt} 44{com}.                         {c )-}
{txt} 45{com}.                 {c )-}
{txt} 46{com}.                 cap drop length1
{txt} 47{com}.                 
.                 rename `var' vv
{txt} 48{com}.                 gen `var'=temp_str1+"."+var_first_tpositions
{txt} 49{com}.                 drop temp_str* var_first_tpositions var_tthpos
{txt} 50{com}.                 replace `var'="" if vv==.
{txt} 51{com}.                 drop vv
{txt} 52{com}.         {c )-}
{txt} 53{com}.         else {c -(}
{txt} 54{com}.                 tostring `var', force replace
{txt} 55{com}.                 drop temp*
{txt} 56{com}.         {c )-}
{txt} 57{com}. end
{txt}
{com}. {txt}
{com}. 
. *---------*
. * Table 1 *
. *---------*
.         * First cutoff: pcs=0.95; this is the cutoff studied in the OAS report
.         *---------------------------------------------------------------------
.         use "data/outputs/computo_verificadortrepdate_nomissings.dta", clear
{txt}
{com}. 
.         * Sort order within identical time stamps affects results
.         * We use a sort order that gives us the median estimate (see Appendix G)
.         gen row = 3
{txt}
{com}.         merge m:1 row using "data/outputs/RD_sortings_mediandraw.dta"
{res}
{txt}{col 5}Result{col 38}# of obs.
{col 5}{hline 41}
{col 5}not matched{col 30}{res}          33,046
{txt}{col 9}from master{col 30}{res}          33,044{txt}  (_merge==1)
{col 9}from using{col 30}{res}               2{txt}  (_merge==2)

{col 5}matched{col 30}{res}               0{txt}  (_merge==3)
{col 5}{hline 41}

{com}.         drop if _merge == 2
{txt}(2 observations deleted)

{com}.         drop _merge row
{txt}
{com}. 
.         merge 1:1 NumMesa sorting using "data/outputs/randomdraws_rd.dta"
{res}
{txt}{col 5}Result{col 38}# of obs.
{col 5}{hline 41}
{col 5}not matched{col 30}{res}          99,132
{txt}{col 9}from master{col 30}{res}          33,044{txt}  (_merge==1)
{col 9}from using{col 30}{res}          66,088{txt}  (_merge==2)

{col 5}matched{col 30}{res}               0{txt}  (_merge==3)
{col 5}{hline 41}

{com}.         drop if _merge == 2
{txt}(66,088 observations deleted)

{com}.         drop _merge sorting
{txt}
{com}. 
.         keep Pais-Nulos trep_date_verificador random_draw
{txt}
{com}. 
.         * Measures that DO USE Blancos and Nulos (sorted)
.         gen total_so = CC + FPV + MTS + UCS + MAS + F + PDC + MNR + PANBOL + ///
>                 Blancos + Nulos
{txt}
{com}.         *---*
.         gen mshare_so = MAS / total_so
{txt}(2 missing values generated)

{com}.         gen cshare_so = CC / total_so
{txt}(2 missing values generated)

{com}.         sort trep_date_verificador random_draw
{txt}
{com}.         gen cumsumtotal_so = sum(total_so)
{txt}
{com}.         *---*
.         egen maxcumsumtotal_so = max(cumsumtotal_so)
{txt}
{com}.         gen pcs_so = cumsumtotal_so / maxcumsumtotal_so
{txt}
{com}.         drop cumsumtotal_so maxcumsumtotal_so
{txt}
{com}. 
.         * Extracting the time stamp of the pcs cutoff of 0.95
.         sum pcs if pcs >= 0.95

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 6}pcs_so {c |}{res}      1,663    .9752186    .0143345   .9500132          1
{txt}
{com}.         local cutoff = r(min)
{txt}
{com}. 
.         gen hour = hh(trep_date) if pcs == `cutoff'
{txt}(33,043 missing values generated)

{com}.         gen min = mm(trep_date) if pcs == `cutoff'
{txt}(33,043 missing values generated)

{com}.         gen secs = ss(trep_date) if pcs == `cutoff'
{txt}(33,043 missing values generated)

{com}.         gen date = dofc(trep_date) if pcs == `cutoff'
{txt}(33,043 missing values generated)

{com}.         format date %td
{txt}
{com}.         gen day = day(date) if pcs == `cutoff'
{txt}(33,043 missing values generated)

{com}.         gen month = month(date) if pcs == `cutoff'
{txt}(33,043 missing values generated)

{com}.         gen year = year(date) if pcs == `cutoff'
{txt}(33,043 missing values generated)

{com}. 
.         global date ""
{txt}
{com}.         foreach g in month day year hour min secs {c -(}
{txt}  2{com}.                 quietly sum `g'
{txt}  3{com}.                 local loc_`g' = r(mean)
{txt}  4{com}.                 drop `g'
{txt}  5{com}.                 global date "$date `loc_`g''"
{txt}  6{com}.         {c )-}
{txt}
{com}.         drop date
{txt}
{com}. 
.         * Generating a variable to cluster at the precinct level
.         egen reci_id = group(Pais Dep Prov Muni Loc Reci)
{txt}
{com}.         
.         * Getting the RD estimate
.         rdrobust mshare pcs, c(0.95) vce(cluster reci_id)
{res}
Sharp RD estimates using local polynomial regression.

{txt}{ralign 18: Cutoff c = .95}{col 19} {c |} {col 21}Left of {res}c{col 33}{txt}Right of {res}c{col 55}{txt}Number of obs = {res}     33042
{txt}{hline 19}{c +}{hline 22}{col 55}BW type       = {res}{ralign 10:mserd}
{txt}{ralign 18:Number of obs}{col 19} {c |} {col 21}{res}    31379{col 34}     1663{col 55}{txt}Kernel        = {res}{ralign 10:Triangular}
{txt}{ralign 18:Eff. Number of obs}{col 19} {c |} {col 21}{res}     1291{col 34}     1345{col 55}{txt}VCE method    = {res}{ralign 10:Cluster}
{txt}{ralign 18:Order est. (p)}{col 19} {c |} {col 21}{res}        1{col 34}        1
{txt}{ralign 18:Order bias (q)}{col 19} {c |} {col 21}{res}        2{col 34}        2
{txt}{ralign 18:BW est. (h)}{col 19} {c |} {col 21}{res}    0.040{col 34}    0.040
{txt}{ralign 18:BW bias (b)}{col 19} {c |} {col 21}{res}    0.045{col 34}    0.045
{txt}{ralign 18:rho (h/b)}{col 19} {c |} {col 21}{res}    0.895{col 34}    0.895
{txt}{ralign 18:Number of clusters}{col 19} {c |} {col 21}{res}      683{col 34}      646

Outcome: mshare. Running variable: pcs.
{txt}{hline 19}{c TT}{hline 60}
{ralign 18:Method}{col 19} {c |} {col 24}Coef.{col 33}Std. Err.{col 46}z{col 52}P>|z|{col 61}[95% Conf. Interval]
{hline 19}{c +}{hline 60}
{ralign 18:Conventional}{col 19} {c |} {col 22}{res} .02742{col 33} .02363{col 43}1.1605{col 52}0.246{col 60}-.018887{col 73} .073722
{txt}{ralign 18:Robust}{col 19} {c |} {col 22}{res}    -{col 33}    -{col 43}0.4765{col 52}0.634{col 60}-.044287{col 73} .072737
{txt}{hline 19}{c BT}{hline 60}
Std. Err. adjusted for clusters in reci_id

{com}.         rdrobust_export mshare pcs, ///
>                 c("0.95") apprep("replace") file("outputs/table1") ///
>                 colstring("Cutoff 0.95 (wrong) - Time $date") ///
>                 vce(cluster reci_id)
{res}
Sharp RD estimates using local polynomial regression.

{txt}{ralign 18: Cutoff c = .95}{col 19} {c |} {col 21}Left of {res}c{col 33}{txt}Right of {res}c{col 55}{txt}Number of obs = {res}     33042
{txt}{hline 19}{c +}{hline 22}{col 55}BW type       = {res}{ralign 10:mserd}
{txt}{ralign 18:Number of obs}{col 19} {c |} {col 21}{res}    31379{col 34}     1663{col 55}{txt}Kernel        = {res}{ralign 10:Triangular}
{txt}{ralign 18:Eff. Number of obs}{col 19} {c |} {col 21}{res}     1291{col 34}     1345{col 55}{txt}VCE method    = {res}{ralign 10:Cluster}
{txt}{ralign 18:Order est. (p)}{col 19} {c |} {col 21}{res}        1{col 34}        1
{txt}{ralign 18:Order bias (q)}{col 19} {c |} {col 21}{res}        2{col 34}        2
{txt}{ralign 18:BW est. (h)}{col 19} {c |} {col 21}{res}    0.040{col 34}    0.040
{txt}{ralign 18:BW bias (b)}{col 19} {c |} {col 21}{res}    0.045{col 34}    0.045
{txt}{ralign 18:rho (h/b)}{col 19} {c |} {col 21}{res}    0.895{col 34}    0.895
{txt}{ralign 18:Number of clusters}{col 19} {c |} {col 21}{res}      683{col 34}      646

Outcome: mshare. Running variable: pcs.
{txt}{hline 19}{c TT}{hline 60}
{ralign 18:Method}{col 19} {c |} {col 24}Coef.{col 33}Std. Err.{col 46}z{col 52}P>|z|{col 61}[95% Conf. Interval]
{hline 19}{c +}{hline 60}
{ralign 18:Conventional}{col 19} {c |} {col 22}{res} .02742{col 33} .02363{col 43}1.1605{col 52}0.246{col 60}-.018887{col 73} .073722
{txt}{ralign 18:Bias-corrected}{col 19} {c |} {col 22}{res} .01422{col 33} .02363{col 43}0.6021{col 52}0.547{col 60} -.03208{col 73}  .06053
{txt}{ralign 18:Robust}{col 19} {c |} {col 22}{res} .01422{col 33} .02985{col 43}0.4765{col 52}0.634{col 60}-.044287{col 73} .072737
{txt}{hline 19}{c BT}{hline 60}
Std. Err. adjusted for clusters in reci_id
{p}
number of observations (_N)  was 0,
now 1
{p_end}
(1 missing value generated)
(1 missing value generated)
(1 missing value generated)
(1 missing value generated)
(1 missing value generated)
(1 missing value generated)
(1 missing value generated)
(1 missing value generated)
(1 missing value generated)
(1 missing value generated)
(1 missing value generated)
(1 missing value generated)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(note: file tempfile.dta not found)
file tempfile.dta saved
(note: file outputs/table1.dta not found)
file outputs/table1.dta saved

{com}. 
.         * Second cutoff: we use the pcs corresponding to 20oct2019 19:40:57
.         *------------------------------------------------------------------
.         use "data/outputs/computo_verificadortrepdate_nomissings.dta", clear
{txt}
{com}. 
.         gen row = 1
{txt}
{com}.         merge m:1 row using "data/outputs/RD_sortings_mediandraw.dta"
{res}
{txt}{col 5}Result{col 38}# of obs.
{col 5}{hline 41}
{col 5}not matched{col 30}{res}               1
{txt}{col 9}from master{col 30}{res}               0{txt}  (_merge==1)
{col 9}from using{col 30}{res}               1{txt}  (_merge==2)

{col 5}matched{col 30}{res}          33,044{txt}  (_merge==3)
{col 5}{hline 41}

{com}.         drop if _merge == 2
{txt}(1 observation deleted)

{com}.         drop _merge row
{txt}
{com}. 
.         merge 1:1 NumMesa sorting using "data/outputs/randomdraws_rd.dta"
{res}
{txt}{col 5}Result{col 38}# of obs.
{col 5}{hline 41}
{col 5}not matched{col 30}{res}          33,044
{txt}{col 9}from master{col 30}{res}               0{txt}  (_merge==1)
{col 9}from using{col 30}{res}          33,044{txt}  (_merge==2)

{col 5}matched{col 30}{res}          33,044{txt}  (_merge==3)
{col 5}{hline 41}

{com}.         drop if _merge == 2
{txt}(33,044 observations deleted)

{com}.         drop _merge sorting
{txt}
{com}. 
.         keep Pais-Nulos trep_date_verificador random_draw
{txt}
{com}. 
.         * Measures that DO USE Blancos and Nulos (sorted)
.         gen total_so = CC + FPV + MTS + UCS + MAS + F + PDC + MNR + PANBOL + ///
>                 Blancos + Nulos
{txt}
{com}.         *---*
.         gen mshare_so = MAS / total_so
{txt}(2 missing values generated)

{com}.         gen cshare_so = CC / total_so
{txt}(2 missing values generated)

{com}.         sort trep_date_verificador random_draw
{txt}
{com}.         gen cumsumtotal_so = sum(total_so)
{txt}
{com}.         *---*
.         egen maxcumsumtotal_so = max(cumsumtotal_so)
{txt}
{com}.         gen pcs_so = cumsumtotal_so / maxcumsumtotal_so
{txt}
{com}.         drop cumsumtotal_so maxcumsumtotal_so
{txt}
{com}. 
.         * Extracting the time stamp of the cutoff of the shutdown
.         sum pcs if trep_date_verificador >= tc(20oct2019 19:40:57)

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 6}pcs_so {c |}{res}      3,612    .9451156    .0322035   .8886026          1
{txt}
{com}.         local cutoff = r(min)
{txt}
{com}. 
.         * Generating a variable to cluster at the precinct level
.         egen reci_id = group(Pais Dep Prov Muni Loc Reci)
{txt}
{com}. 
.         * Getting the RD estimate
.         rdrobust mshare pcs, c(`cutoff') vce(cluster reci_id)
{res}
Sharp RD estimates using local polynomial regression.

{txt}{ralign 18: Cutoff c = .888602614402771}{col 19} {c |} {col 21}Left of {res}c{col 33}{txt}Right of {res}c{col 55}{txt}Number of obs = {res}     33042
{txt}{hline 19}{c +}{hline 22}{col 55}BW type       = {res}{ralign 10:mserd}
{txt}{ralign 18:Number of obs}{col 19} {c |} {col 21}{res}    29430{col 34}     3612{col 55}{txt}Kernel        = {res}{ralign 10:Triangular}
{txt}{ralign 18:Eff. Number of obs}{col 19} {c |} {col 21}{res}     1248{col 34}     1245{col 55}{txt}VCE method    = {res}{ralign 10:Cluster}
{txt}{ralign 18:Order est. (p)}{col 19} {c |} {col 21}{res}        1{col 34}        1
{txt}{ralign 18:Order bias (q)}{col 19} {c |} {col 21}{res}        2{col 34}        2
{txt}{ralign 18:BW est. (h)}{col 19} {c |} {col 21}{res}    0.039{col 34}    0.039
{txt}{ralign 18:BW bias (b)}{col 19} {c |} {col 21}{res}    0.056{col 34}    0.056
{txt}{ralign 18:rho (h/b)}{col 19} {c |} {col 21}{res}    0.705{col 34}    0.705
{txt}{ralign 18:Number of clusters}{col 19} {c |} {col 21}{res}      957{col 34}      789

Outcome: mshare. Running variable: pcs.
{txt}{hline 19}{c TT}{hline 60}
{ralign 18:Method}{col 19} {c |} {col 24}Coef.{col 33}Std. Err.{col 46}z{col 52}P>|z|{col 61}[95% Conf. Interval]
{hline 19}{c +}{hline 60}
{ralign 18:Conventional}{col 19} {c |} {col 22}{res}  -.018{col 33} .02408{col 43}-0.7475{col 52}0.455{col 60}-.065193{col 73} .029193
{txt}{ralign 18:Robust}{col 19} {c |} {col 22}{res}    -{col 33}    -{col 43}-0.3576{col 52}0.721{col 60}-.064963{col 73} .044917
{txt}{hline 19}{c BT}{hline 60}
Std. Err. adjusted for clusters in reci_id

{com}.         rdrobust_export mshare pcs, ///
>                 c("`cutoff'") apprep("append") file("outputs/table1") ///
>                 colstring("Cutoff `cutoff' - Time 10 20 2019 19 40 57") ///
>                 vce(cluster reci_id)
{res}
Sharp RD estimates using local polynomial regression.

{txt}{ralign 18: Cutoff c = .888602614402771}{col 19} {c |} {col 21}Left of {res}c{col 33}{txt}Right of {res}c{col 55}{txt}Number of obs = {res}     33042
{txt}{hline 19}{c +}{hline 22}{col 55}BW type       = {res}{ralign 10:mserd}
{txt}{ralign 18:Number of obs}{col 19} {c |} {col 21}{res}    29430{col 34}     3612{col 55}{txt}Kernel        = {res}{ralign 10:Triangular}
{txt}{ralign 18:Eff. Number of obs}{col 19} {c |} {col 21}{res}     1248{col 34}     1245{col 55}{txt}VCE method    = {res}{ralign 10:Cluster}
{txt}{ralign 18:Order est. (p)}{col 19} {c |} {col 21}{res}        1{col 34}        1
{txt}{ralign 18:Order bias (q)}{col 19} {c |} {col 21}{res}        2{col 34}        2
{txt}{ralign 18:BW est. (h)}{col 19} {c |} {col 21}{res}    0.039{col 34}    0.039
{txt}{ralign 18:BW bias (b)}{col 19} {c |} {col 21}{res}    0.056{col 34}    0.056
{txt}{ralign 18:rho (h/b)}{col 19} {c |} {col 21}{res}    0.705{col 34}    0.705
{txt}{ralign 18:Number of clusters}{col 19} {c |} {col 21}{res}      957{col 34}      789

Outcome: mshare. Running variable: pcs.
{txt}{hline 19}{c TT}{hline 60}
{ralign 18:Method}{col 19} {c |} {col 24}Coef.{col 33}Std. Err.{col 46}z{col 52}P>|z|{col 61}[95% Conf. Interval]
{hline 19}{c +}{hline 60}
{ralign 18:Conventional}{col 19} {c |} {col 22}{res}  -.018{col 33} .02408{col 43}-0.7475{col 52}0.455{col 60}-.065193{col 73} .029193
{txt}{ralign 18:Bias-corrected}{col 19} {c |} {col 22}{res}-.01002{col 33} .02408{col 43}-0.4163{col 52}0.677{col 60}-.057216{col 73}  .03717
{txt}{ralign 18:Robust}{col 19} {c |} {col 22}{res}-.01002{col 33} .02803{col 43}-0.3576{col 52}0.721{col 60}-.064963{col 73} .044917
{txt}{hline 19}{c BT}{hline 60}
Std. Err. adjusted for clusters in reci_id
{p}
number of observations (_N)  was 0,
now 1
{p_end}
(1 missing value generated)
(1 missing value generated)
(1 missing value generated)
(1 missing value generated)
(1 missing value generated)
(1 missing value generated)
(1 missing value generated)
(1 missing value generated)
(1 missing value generated)
(1 missing value generated)
(1 missing value generated)
(1 missing value generated)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(note: file tempfile.dta not found)
file tempfile.dta saved
file outputs/table1.dta saved

{com}. 
.         * Formatting the results table
.         *-----------------------------
.         use "outputs/table1.dta", clear
{txt}
{com}.         drop obs band_r conv_*
{txt}
{com}. 
.         foreach x of varlist estim-rob_ci_high {c -(}
{txt}  2{com}.                 myround `x', decimals(3)
{txt}  3{com}.         {c )-}
{txt}temp_str generated as {res:str12}
temp_str was forced to string; some loss of information
(0 real changes made)
(0 real changes made)
{res}variables created as string: 
{txt}{col 1}temp_str1{col 12}temp_str2
(1 real change made)
variable {bf}temp_str1{sf} was {bf}{res}str1{sf}{txt} now {bf}{res}str2{sf}
{txt}(1 real change made)
(0 real changes made)
var_first_tpositions: all characters numeric; {res}replaced {txt}as {res}byte
{txt}var_tthpos: all characters numeric; {res}replaced {txt}as {res}byte
{txt}(1 real change made)
(0 real changes made)
var_first_tpositions was {res:byte} now {res:str2}
variable {bf}var_first_tpositions{sf} was {bf}{res}str2{sf}{txt} now {bf}{res}str3{sf}
{txt}(2 real changes made)
{res}{txt}(0 real changes made)
temp_str generated as {res:str11}
temp_str was forced to string; some loss of information
(0 real changes made)
(0 real changes made)
{res}variables created as string: 
{txt}{col 1}temp_str1{col 12}temp_str2
(2 real changes made)
(0 real changes made)
(0 real changes made)
var_first_tpositions: all characters numeric; {res}replaced {txt}as {res}byte
{txt}var_tthpos: all characters numeric; {res}replaced {txt}as {res}byte
{txt}(0 real changes made)
(0 real changes made)
var_first_tpositions was {res:byte} now {res:str2}
variable {bf}var_first_tpositions{sf} was {bf}{res}str2{sf}{txt} now {bf}{res}str3{sf}
{txt}(2 real changes made)
{res}{txt}(0 real changes made)
temp_str generated as {res:str11}
temp_str was forced to string; some loss of information
(0 real changes made)
(0 real changes made)
{res}variables created as string: 
{txt}{col 1}temp_str1{col 12}temp_str2
(2 real changes made)
(0 real changes made)
(0 real changes made)
var_first_tpositions: all characters numeric; {res}replaced {txt}as {res}int
{txt}var_tthpos: all characters numeric; {res}replaced {txt}as {res}byte
{txt}(2 real changes made)
(0 real changes made)
var_first_tpositions was {res:int} now {res:str3}
(0 real changes made)
{res}{txt}(0 real changes made)
temp_str generated as {res:str12}
temp_str was forced to string; some loss of information
(0 real changes made)
(0 real changes made)
{res}variables created as string: 
{txt}{col 1}temp_str1{col 12}temp_str2
(0 real changes made)
variable {bf}temp_str1{sf} was {bf}{res}str1{sf}{txt} now {bf}{res}str2{sf}
{txt}(2 real changes made)
(0 real changes made)
var_first_tpositions: all characters numeric; {res}replaced {txt}as {res}byte
{txt}var_tthpos: all characters numeric; {res}replaced {txt}as {res}byte
{txt}(1 real change made)
(0 real changes made)
var_first_tpositions was {res:byte} now {res:str2}
variable {bf}var_first_tpositions{sf} was {bf}{res}str2{sf}{txt} now {bf}{res}str3{sf}
{txt}(2 real changes made)
{res}{txt}(0 real changes made)
temp_str generated as {res:str11}
temp_str was forced to string; some loss of information
(0 real changes made)
(0 real changes made)
{res}variables created as string: 
{txt}{col 1}temp_str1{col 12}temp_str2
(2 real changes made)
(0 real changes made)
(0 real changes made)
var_first_tpositions: all characters numeric; {res}replaced {txt}as {res}byte
{txt}var_tthpos: all characters numeric; {res}replaced {txt}as {res}byte
{txt}(2 real changes made)
(0 real changes made)
var_first_tpositions was {res:byte} now {res:str2}
variable {bf}var_first_tpositions{sf} was {bf}{res}str2{sf}{txt} now {bf}{res}str3{sf}
{txt}(2 real changes made)
{res}{txt}(0 real changes made)

{com}.         tostring obs_l obs_r, force replace
{txt}obs_l was {res:float} now {res:str4}
obs_r was {res:float} now {res:str4}

{com}. 
.         gen rob_ci = "[" + rob_ci_low + ", " + rob_ci_high + "]"
{txt}
{com}.         drop rob_ci_low rob_ci_high
{txt}
{com}. 
.         split colstring, p("-")
{res}variables created as string: 
{txt}{col 1}colstring1{col 13}colstring2

{com}.         drop colstring
{txt}
{com}. 
.         rename colstring2 time
{res}{txt}
{com}.         replace time = subinstr(time,"Time ","",.)
{txt}(2 real changes made)

{com}.         split time, p(" ")
{res}variables created as string: 
{txt}{col 1}time1{col 8}time2{col 15}time3{col 22}time4{col 29}time5{col 36}time6

{com}.         split time6, p(".")
{res}variables created as string: 
{txt}{col 1}time61{col 9}time62

{com}.         drop time
{txt}
{com}.         replace time5 = "0" + time5 if length(time5) == 1
{txt}(1 real change made)

{com}.         gen time = time1 + "/" + time2 + "/" + time3 + " " + time4 + ":" + time5 + ///
>                 ":" + time61
{txt}
{com}.         drop time1 time2 time3 time4 time5 time6*
{txt}
{com}. 
.         split colstring1, p(" ")
{res}variables created as string: 
{txt}{col 1}colstring11{col 14}colstring12{col 27}colstring13

{com}.         drop colstring1 colstring11 colstring13
{txt}
{com}.         rename colstring12 cutoff
{res}{txt}
{com}.         destring cutoff, replace
{txt}cutoff: all characters numeric; {res}replaced {txt}as {res}double
{txt}
{com}.         myround cutoff, decimals(3)
{txt}temp_str generated as {res:str11}
temp_str was forced to string; some loss of information
(0 real changes made)
(0 real changes made)
{res}variables created as string: 
{txt}{col 1}temp_str1{col 12}temp_str2
(2 real changes made)
(0 real changes made)
(1 real change made)
(1 real change made)
var_first_tpositions: all characters numeric; {res}replaced {txt}as {res}int
{txt}var_tthpos: all characters numeric; {res}replaced {txt}as {res}byte
{txt}(1 real change made)
(0 real changes made)
var_first_tpositions was {res:int} now {res:str3}
(0 real changes made)
{res}{txt}(0 real changes made)

{com}. 
.         replace obs_l=subinstr(obs_l,"13","1,3",.)
{txt}(0 real changes made)

{com}.         replace obs_l=subinstr(obs_l,"12","1,2",.)
{txt}variable {bf}obs_l{sf} was {bf}{res}str4{sf}{txt} now {bf}{res}str5{sf}
{txt}(2 real changes made)

{com}.         replace obs_r=subinstr(obs_r,"13","1,3",.)
{txt}variable {bf}obs_r{sf} was {bf}{res}str4{sf}{txt} now {bf}{res}str5{sf}
{txt}(1 real change made)

{com}.         replace obs_r=subinstr(obs_r,"12","1,2",.)
{txt}(1 real change made)

{com}. 
.         egen c = concat(cutoff time estim band_l rob_pv rob_ci obs_l obs_r), ///
>                 punct(" & ")
{txt}
{com}.         keep c
{txt}
{com}.         replace c = c + " \\"
{txt}(2 real changes made)

{com}. 
.         outsheet using "outputs/generated/Table_1.tex", replace noquote ///
>                 nolabel noname
{txt}(note: file outputs/generated/Table_1.tex not found)

{com}.         erase "outputs/table1.dta"
{txt}
{com}. 
. *------------------------------------------------------------------------------*
. timer off 2
{txt}
{com}. timer list 2
{res}   2:      0.75 /        1 =       0.7480
{txt}
{com}. 
. log close
      {txt}name:  {res}<unnamed>
       {txt}log:  {res}E:\Github\Bolivia\00_replication_files\log-files/3_Table_1.smcl
  {txt}log type:  {res}smcl
 {txt}closed on:  {res}25 Jan 2022, 22:40:01
{txt}{.-}
{smcl}
{txt}{sf}{ul off}